
// 引用mysql
const mysql = require('mysql')
// 配置数据库信息
const connection = mysql.createConnection({
    host: 'localhost',
    port: '3306',
    user: 'root',
    password: '123456',
    database: 'books'
});
function query(sql) {
    return new Promise((resolve, reject) => {
        connection.query(sql, function (err, rows) {
            if (err) { throw err }
            resolve(rows)
        });
    })
}

module.exports = query
